<?php
class Login extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('url');
		session_start();
	}
	function index(){
		$this->load->view("admin/login/v_login");
	}
	function action_post(){
		foreach ($_POST as $key=>$v){
			if($key == "admin_pass"){
				$where[$key] = md5(trim($v));
			}else 
				$where[$key] = trim($v);
		}
		$admin_list = $this->m_tbk->getOne("admin",$where);
		if($admin_list !="" ){
			$_SESSION["admin_id"] = $admin_list["id"];
			header("Location:".site_url('admin/index'));
		}else{
			$lang ["waitSecond"] = 5;
			$lang ["jumpUrl"] = site_url("admin/login");
			$lang ["msg"] = "登入失败！请检查账号密码是否正确";
			$this->load->view ( 'public/v_error', $lang );
		}
	}
	function loginout(){
		$_SESSION["admin_id"] = "";
		session_destroy();
		header("Location:".site_url('admin/login'));
	}
}